package com.neuedu.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;



public class BaseDao {
	public static final String DRIVER = "com.mysql.cj.jdbc.Driver";
	public static final String URL = "jdbc:mysql://localhost:3306/test0715";
	public static final String USENRMAE = "root";
	public static final String PASSWORD = "qwe123";
	private static Connection connection ;
	
	static {
		try {
			Class.forName(DRIVER);
			connection = DriverManager.getConnection(URL, USENRMAE, PASSWORD);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	} 
	
	public static Connection getConnection() {
		return connection;
	}
	
	
	public static void close(Statement stmt) {
		try {
			if(stmt!=null) {
				stmt.close();
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	public static void close(ResultSet rs ,Statement stmt) {
		try {
			if(rs!=null) {
				rs.close();
			}
			
			if(stmt!=null) {
				stmt.close();
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	public static void close() {
		try {
			if(connection!=null) {
				connection.close();
			}
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
